package com.example.demo.service.impl;

import com.example.demo.dao.AddressDao;
import com.example.demo.pojo.Address;
import com.example.demo.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl  implements AddressService {

    @Autowired
    private AddressDao addressDao;

    //通过用户id查询收货地址
    @Override
    public List<Address> selectByUserId(int userid) {
        return addressDao.selectByUserId(userid);
    }

    //新增收货地址
    @Override
    public int insert(Address address) {
        return addressDao.insertSelective(address);
    }

    //通过地址id删除收货地址
    @Override
    public int delectByAdddress(Integer id) {
        return addressDao.deleteByPrimaryKey(id);
    }

    //修改收货地址
    @Override
    public int updateByAddress(Address address) {
        return addressDao.updateByPrimaryKeySelective(address);
    }

    @Override
    public List<Address> selectByisdefault(int isdefault) {
        return addressDao.selectByisdefault(isdefault);
    }
}
